package com.jiawa.train.batch.feign;

import com.jiawa.train.common.resp.CommonResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class BusinessFeignFallBack implements FallbackFactory<BusinessFeign> {
    @Override
    public BusinessFeign create(Throwable cause) {
        log.error("Feign client fallback triggered", cause);
        return new BusinessFeign() {
            @Override
            public CommonResp<Object> generate(Date date) {
                log.error("调用业务服务失败,启动降级服务");
                return null;
            }
        };
    }
}
